package com.szholly.plug.activity.interceptor.defulat;

import java.util.Date;

import org.springframework.stereotype.Component;

import com.szholly.plug.activity.interceptor.BpmHandleOptionBase;
import com.szholly.plug.activity.interceptor.BpmInterceptorRegister;
import com.szholly.plug.activity.interceptor.OptionInfo;
import com.szholly.plug.activity.model.BpmHistoryRow;
import com.szholly.plug.activity.model.BpmHistoryTable;

/**
 * 审批历史处理
 */
@Component
public class HistoryBpmOption extends BpmHandleOptionBase {
	
	/**
	 * 注册拦截接口
	 */
	static {
		HistoryBpmOption interceptor = new HistoryBpmOption();
		BpmInterceptorRegister.RegDbInterceptor(interceptor);
	}
	
	/**
	 * 流程任务操作
	 * @param optionInfo
	 */
	@Override
	public void taskOption(OptionInfo optionInfo){
		// 获取审批历史中的字段信息
		BpmHistoryRow historyRow = new BpmHistoryRow();
		historyRow.setSExeid(optionInfo.TaskProid);
		historyRow.setStakId(optionInfo.TaskDefinitionKey);
		historyRow.setSStakname(optionInfo.TaskPState);
		historyRow.setSOption(optionInfo.TaskOption);
		historyRow.setSOptioncontent(optionInfo.TaskOptionContent);
		historyRow.setNextStakname(optionInfo.TaskState);
		historyRow.setAssignees(optionInfo.TaskAssigneesName);
		historyRow.setAssigneesId(optionInfo.TaskAssigneesId);
		historyRow.setSOptiontime(new Date());
		BpmHistoryTable.getSingleRef().SaveEntityInThread(historyRow);
	}
}